﻿Public Class Backup

    Private Sub Backup_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Main.ListBox1.Items.Add("(" + DateTime.Now & ") - Backing Up World...")
        OpenFileDialog1.Title = "Please Select the World"
        OpenFileDialog1.FileName = "Choose World..."
        OpenFileDialog1.Filter = ".wld Files (*.wld)|*.wld|All Files (*.*)|*.*"
        OpenFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\My Games\Terraria\Worlds"
        OpenFileDialog1.ShowDialog()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        SaveFileDialog1.Title = "Backup Your World"
        SaveFileDialog1.FileName = OpenFileDialog1.SafeFileName
        SaveFileDialog1.Filter = ".wld File (*.wld)|*.wld"
        SaveFileDialog1.ShowDialog()
    End Sub

    Private Sub SaveFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles SaveFileDialog1.FileOk
        FileCopy(OpenFileDialog1.FileName, SaveFileDialog1.FileName)
        Main.ListBox1.Items.Add("(" + DateTime.Now & ") - Back Up Successful")
        Me.Hide()
    End Sub
End Class